home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 October: Mac OS SDK / Dev.CD Oct 00 SDK1.toast / Development Kits / Cross Platform / QuickTime 4.1.2 Windows SDK / CIncludes / MacTCP.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-12  |  25.7 KB  |  838 lines  |  [TEXT/R*ch]

  1. /*
  2.      File:        MacTCP.h
  3.  
  4.      Contains:    TCP Manager Interfaces.
  5.  
  6.      Version:    Technology:    MacTCP 2.0.6
  7.                  Release:    QuickTime 4.1
  8.  
  9.      Copyright:    (c) 1989-1999 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __MACTCP__
  18. #define __MACTCP__
  19.  
  20. #ifndef __MACTYPES__
  21.     #include <MacTypes.h>
  22. #endif
  23.  
  24. #ifndef __MIXEDMODE__
  25.     #include <MixedMode.h>
  26. #endif
  27.  
  28. #ifndef __APPLETALK__
  29.     #include <AppleTalk.h>
  30. #endif
  31.  
  32.  
  33.  
  34.  
  35. #if PRAGMA_ONCE
  36. #pragma once
  37. #endif
  38.  
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42.  
  43. #if PRAGMA_IMPORT
  44. #pragma import on
  45. #endif
  46.  
  47. #if PRAGMA_STRUCT_ALIGN
  48.     #pragma options align=mac68k
  49. #elif PRAGMA_STRUCT_PACKPUSH
  50.     #pragma pack(push, 2)
  51. #elif PRAGMA_STRUCT_PACK
  52.     #pragma pack(2)
  53. #endif
  54.  
  55. /*
  56. Developer Notes:
  57.         0. This MacTCP header replaces what used to be defined in the following header files
  58.             MacTCPCommonTypes.h
  59.             GetMyIPAddr.h
  60.             MiscIPPB.h
  61.             TCPPB.h
  62.             UDPPB.h 
  63.             
  64.             When the various control calls are made to the ip driver, you must set up a 
  65.             NewRoutineDescriptor for every non-nil completion routine and/or notifyProc parameter.  
  66.             Otherwise, the 68K driver code, will not correctly call your routine.
  67.         1. For ipctlGetAddr Control calls, use NewGetIPIOCompletionProc
  68.             to set up a GetIPIOCompletionUPP universal procptr to pass as
  69.             the ioCompletion parameter.
  70.         2. For the ipctlEchoICMP and ipctlLAPStats Control calls, use 
  71.             NewIPIOCompletion to set up a IPIOCompletionUPP universal procptr
  72.             to pass in the ioCompletion field of the parameter block.
  73.         3. For TCPCreatePB Control calls, use NewTCPNotifyProc to set up a
  74.             TCPNotifyUPP universal procptr to pass in the notifyProc field
  75.             of the parameter block
  76.         4. For all of the TCP Control calls using the TCPiopb parameter block,
  77.             use NewTCPIOCompletionProc to set up a TCPIOCompletionUPP
  78.             universal procptr to pass in the ioCompletion field of the paramter
  79.             block.
  80.         5. For UDBCreatePB Control calls, use NewUDPNotifyProc to set up a
  81.             UDPNotifyUPP universal procptr to pass in the notifyProc field
  82.             of the parameter block
  83.         6. For all of the UDP Control calls using the UDPiopb parameter block,
  84.             use NewUDPIOCompletionProc to set up a UDPIOCompletionUPP
  85.             universal procptr to pass in the ioCompletion field of the paramter
  86.             block.
  87.         7. For all calls implementing a notifyProc or ioCompletion routine
  88.             which was set up using a NewTCPRoutineProc call, do not call
  89.             DisposeRoutineSDescriptor on the universal procptr until
  90.             after the completion or notify proc has completed.
  91. */
  92.  
  93. /* MacTCP return Codes in the range -23000 through -23049 */
  94. enum {
  95.     inProgress                    = 1,                            /* I/O in progress */
  96.     ipBadLapErr                    = -23000,                        /* bad network configuration */
  97.     ipBadCnfgErr                = -23001,                        /* bad IP configuration error */
  98.     ipNoCnfgErr                    = -23002,                        /* missing IP or LAP configuration error */
  99.     ipLoadErr                    = -23003,                        /* error in MacTCP load */
  100.     ipBadAddr                    = -23004,                        /* error in getting address */
  101.     connectionClosing            = -23005,                        /* connection is closing */
  102.     invalidLength                = -23006,
  103.     connectionExists            = -23007,                        /* request conflicts with existing connection */
  104.     connectionDoesntExist        = -23008,                        /* connection does not exist */
  105.     insufficientResources        = -23009,                        /* insufficient resources to perform request */
  106.     invalidStreamPtr            = -23010,
  107.     streamAlreadyOpen            = -23011,
  108.     connectionTerminated        = -23012,
  109.     invalidBufPtr                = -23013,
  110.     invalidRDS                    = -23014,
  111.     invalidWDS                    = -23014,
  112.     openFailed                    = -23015,
  113.     commandTimeout                = -23016,
  114.     duplicateSocket                = -23017
  115. };
  116.  
  117. /* Error codes from internal IP functions */
  118. enum {
  119.     ipDontFragErr                = -23032,                        /* Packet too large to send w/o fragmenting */
  120.     ipDestDeadErr                = -23033,                        /* destination not responding */
  121.     icmpEchoTimeoutErr            = -23035,                        /* ICMP echo timed-out */
  122.     ipNoFragMemErr                = -23036,                        /* no memory to send fragmented pkt */
  123.     ipRouteErr                    = -23037,                        /* can't route packet off-net */
  124.     nameSyntaxErr                = -23041,
  125.     cacheFault                    = -23042,
  126.     noResultProc                = -23043,
  127.     noNameServer                = -23044,
  128.     authNameErr                    = -23045,
  129.     noAnsErr                    = -23046,
  130.     dnrErr                        = -23047,
  131.     outOfMemory                    = -23048
  132. };
  133.  
  134.  
  135. enum {
  136.     BYTES_16WORD                = 2,                            /* bytes per = 16, bit ip word */
  137.     BYTES_32WORD                = 4,                            /* bytes per = 32, bit ip word */
  138.     BYTES_64WORD                = 8                                /* bytes per = 64, bit ip word */
  139. };
  140.  
  141. /* 8-bit quantity */
  142. typedef UInt8                             b_8;
  143. /* 16-bit quantity */
  144. typedef UInt16                             b_16;
  145. /* 32-bit quantity */
  146. typedef UInt32                             b_32;
  147. /* IP address is 32-bits */
  148. typedef b_32                             ip_addr;
  149.  
  150. struct ip_addrbytes {
  151.     union {
  152.         b_32                             addr;
  153.         UInt8                             byte[4];
  154.     }                                 a;
  155. };
  156. typedef struct ip_addrbytes                ip_addrbytes;
  157.  
  158. struct wdsEntry {
  159.     unsigned short                     length;                        /* length of buffer */
  160.     Ptr                             ptr;                        /* pointer to buffer */
  161. };
  162. typedef struct wdsEntry                    wdsEntry;
  163.  
  164. struct rdsEntry {
  165.     unsigned short                     length;                        /* length of buffer */
  166.     Ptr                             ptr;                        /* pointer to buffer */
  167. };
  168. typedef struct rdsEntry                    rdsEntry;
  169.  
  170. typedef unsigned long                     BufferPtr;
  171. typedef unsigned long                     StreamPtr;
  172. enum {
  173.     netUnreach                    = 0,
  174.     hostUnreach                    = 1,
  175.     protocolUnreach                = 2,
  176.     portUnreach                    = 3,
  177.     fragReqd                    = 4,
  178.     sourceRouteFailed            = 5,
  179.     timeExceeded                = 6,
  180.     parmProblem                    = 7,
  181.     missingOption                = 8,
  182.     lastICMPMsgType                = 32767
  183. };
  184.  
  185. typedef unsigned short                     ICMPMsgType;
  186. typedef b_16                             ip_port;
  187.  
  188. struct ICMPReport {
  189.     StreamPtr                         streamPtr;
  190.     ip_addr                         localHost;
  191.     ip_port                         localPort;
  192.     ip_addr                         remoteHost;
  193.     ip_port                         remotePort;
  194.     short                             reportType;
  195.     unsigned short                     optionalAddlInfo;
  196.     unsigned long                     optionalAddlInfoPtr;
  197. };
  198. typedef struct ICMPReport                ICMPReport;
  199. /* csCode to get our IP address */
  200. enum {
  201.     ipctlGetAddr                = 15
  202. };
  203.  
  204. typedef struct GetAddrParamBlock         GetAddrParamBlock;
  205. typedef CALLBACK_API_C( void , GetIPIOCompletionProcPtr )(GetAddrParamBlock *iopb);
  206. typedef STACK_UPP_TYPE(GetIPIOCompletionProcPtr)                 GetIPIOCompletionUPP;
  207.  
  208. struct GetAddrParamBlock {
  209.     QElem *                            qLink;
  210.     short                             qType;
  211.     short                             ioTrap;
  212.     Ptr                             ioCmdAddr;
  213.     GetIPIOCompletionUPP             ioCompletion;
  214.     OSErr                             ioResult;
  215.     StringPtr                         ioNamePtr;
  216.     short                             ioVRefNum;
  217.     short                             ioCRefNum;
  218.     short                             csCode;
  219.     ip_addr                         ourAddress;                    /* our IP address */
  220.     long                             ourNetMask;                    /* our IP net mask */
  221. };
  222.  
  223. /* control codes */
  224. enum {
  225.     ipctlEchoICMP                = 17,                            /* send icmp echo */
  226.     ipctlLAPStats                = 19                            /* get lap stats */
  227. };
  228.  
  229.  
  230. typedef struct ICMPParamBlock             ICMPParamBlock;
  231. typedef CALLBACK_API_C( void , IPIOCompletionProcPtr )(ICMPParamBlock *iopb);
  232. typedef STACK_UPP_TYPE(IPIOCompletionProcPtr)                     IPIOCompletionUPP;
  233.  
  234. struct ICMPParamBlock {
  235.     QElem *                            qLink;
  236.     short                             qType;
  237.     short                             ioTrap;
  238.     Ptr                             ioCmdAddr;
  239.     IPIOCompletionUPP                 ioCompletion;
  240.     OSErr                             ioResult;
  241.     StringPtr                         ioNamePtr;
  242.     short                             ioVRefNum;
  243.     short                             ioCRefNum;
  244.     short                             csCode;
  245.     short                             params[11];
  246.     struct {
  247.         unsigned long                     echoRequestOut;            /* time in ticks of when the echo request went out */
  248.         unsigned long                     echoReplyIn;            /* time in ticks of when the reply was received */
  249.         rdsEntry                         echoedData;                /* data received in responce */
  250.         Ptr                             options;
  251.         unsigned long                     userDataPtr;
  252.     }                                 icmpEchoInfo;
  253. };
  254.  
  255. typedef CALLBACK_API_C( void , ICMPEchoNotifyProcPtr )(ICMPParamBlock *iopb);
  256. typedef STACK_UPP_TYPE(ICMPEchoNotifyProcPtr)                     ICMPEchoNotifyUPP;
  257. typedef struct LAPStats                 LAPStats;
  258.  
  259. struct IPParamBlock {
  260.     QElem *                            qLink;
  261.     short                             qType;
  262.     short                             ioTrap;
  263.     Ptr                             ioCmdAddr;
  264.     IPIOCompletionUPP                 ioCompletion;
  265.     OSErr                             ioResult;
  266.     StringPtr                         ioNamePtr;
  267.     short                             ioVRefNum;
  268.     short                             ioCRefNum;
  269.     short                             csCode;
  270.     union {
  271.         struct {
  272.             ip_addr                         dest;                /* echo to IP address */
  273.             wdsEntry                         data;
  274.             short                             timeout;
  275.             Ptr                             options;
  276.             unsigned short                     optLength;
  277.             ICMPEchoNotifyUPP                 icmpCompletion;
  278.             unsigned long                     userDataPtr;
  279.         }                                 IPEchoPB;
  280.         struct {
  281.             LAPStats *                        lapStatsPtr;
  282.         }                                 LAPStatsPB;
  283.     }                                 csParam;
  284. };
  285. typedef struct IPParamBlock                IPParamBlock;
  286.  
  287.  
  288. struct nbp_entry {
  289.     ip_addr                         ip_address;                    /* IP address */
  290.     AddrBlock                         at_address;                    /* matching AppleTalk address */
  291.     Boolean                         gateway;                    /* TRUE if entry for a gateway */
  292.     Boolean                         valid;                        /* TRUE if LAP address is valid */
  293.     Boolean                         probing;                    /* TRUE if NBP lookup pending */
  294.     SInt8                             afiller;                    /* Filler for proper byte alignment     */
  295.     long                             age;                        /* ticks since cache entry verified */
  296.     long                             access;                        /* ticks since last access */
  297.     SInt8                             filler[116];                /* for internal use only !!! */
  298. };
  299. typedef struct nbp_entry                nbp_entry;
  300.  
  301. struct Enet_addr {
  302.     b_16                             en_hi;
  303.     b_32                             en_lo;
  304. };
  305. typedef struct Enet_addr                Enet_addr;
  306.  
  307. struct arp_entry {
  308.     short                             age;                        /* cache aging field */
  309.     b_16                             protocol;                    /* Protocol type */
  310.     ip_addr                         ip_address;                    /* IP address */
  311.     Enet_addr                         en_address;                    /* matching Ethernet address */
  312. };
  313. typedef struct arp_entry                arp_entry;
  314.  
  315. union LAPStatsAddrXlation {
  316.     arp_entry *                        arp_table;
  317.     nbp_entry *                        nbp_table;
  318. };
  319. typedef union LAPStatsAddrXlation        LAPStatsAddrXlation;
  320.  
  321. struct LAPStats {
  322.     short                             ifType;
  323.     char *                            ifString;
  324.     short                             ifMaxMTU;
  325.     long                             ifSpeed;
  326.     short                             ifPhyAddrLength;
  327.     char *                            ifPhysicalAddress;
  328.     LAPStatsAddrXlation             AddrXlation;
  329.     short                             slotNumber;
  330. };
  331.  
  332. /* number of ARP table entries */
  333. enum {
  334.     ARP_TABLE_SIZE                = 20
  335. };
  336.  
  337. enum {
  338.     NBP_TABLE_SIZE                = 20,                            /* number of NBP table entries */
  339.     NBP_MAX_NAME_SIZE            = 16 + 10 + 2
  340. };
  341.  
  342.  
  343.  
  344. /* Command codes */
  345. enum {
  346.     TCPCreate                    = 30,
  347.     TCPPassiveOpen                = 31,
  348.     TCPActiveOpen                = 32,
  349.     TCPSend                        = 34,
  350.     TCPNoCopyRcv                = 35,
  351.     TCPRcvBfrReturn                = 36,
  352.     TCPRcv                        = 37,
  353.     TCPClose                    = 38,
  354.     TCPAbort                    = 39,
  355.     TCPStatus                    = 40,
  356.     TCPExtendedStat                = 41,
  357.     TCPRelease                    = 42,
  358.     TCPGlobalInfo                = 43,
  359.     TCPCtlMax                    = 49
  360. };
  361.  
  362. enum {
  363.     TCPClosing                    = 1,
  364.     TCPULPTimeout                = 2,
  365.     TCPTerminate                = 3,
  366.     TCPDataArrival                = 4,
  367.     TCPUrgent                    = 5,
  368.     TCPICMPReceived                = 6,
  369.     lastEvent                    = 32767
  370. };
  371.  
  372.  
  373. typedef unsigned short                     TCPEventCode;
  374. enum {
  375.     TCPRemoteAbort                = 2,
  376.     TCPNetworkFailure            = 3,
  377.     TCPSecPrecMismatch            = 4,
  378.     TCPULPTimeoutTerminate        = 5,
  379.     TCPULPAbort                    = 6,
  380.     TCPULPClose                    = 7,
  381.     TCPServiceError                = 8,
  382.     lastReason                    = 32767
  383. };
  384.  
  385. typedef unsigned short                     TCPTerminationReason;
  386. typedef CALLBACK_API( void , TCPNotifyProcPtr )(StreamPtr tcpStream, unsigned short eventCode, Ptr userDataPtr, unsigned short terminReason, ICMPReport *icmpMsg);
  387. typedef STACK_UPP_TYPE(TCPNotifyProcPtr)                         TCPNotifyUPP;
  388. typedef unsigned short                     tcp_port;
  389. /* ValidityFlags */
  390. enum {
  391.     timeoutValue                = 0x80,
  392.     timeoutAction                = 0x40,
  393.     typeOfService                = 0x20,
  394.     precedence                    = 0x10
  395. };
  396.  
  397. /* TOSFlags */
  398. enum {
  399.     lowDelay                    = 0x01,
  400.     throughPut                    = 0x02,
  401.     reliability                    = 0x04
  402. };
  403.  
  404.  
  405. struct TCPCreatePB {
  406.     Ptr                             rcvBuff;
  407.     unsigned long                     rcvBuffLen;
  408.     TCPNotifyUPP                     notifyProc;
  409.     Ptr                             userDataPtr;
  410. };
  411. typedef struct TCPCreatePB                TCPCreatePB;
  412.  
  413. struct TCPOpenPB {
  414.     SInt8                             ulpTimeoutValue;
  415.     SInt8                             ulpTimeoutAction;
  416.     SInt8                             validityFlags;
  417.     SInt8                             commandTimeoutValue;
  418.     ip_addr                         remoteHost;
  419.     tcp_port                         remotePort;
  420.     ip_addr                         localHost;
  421.     tcp_port                         localPort;
  422.     SInt8                             tosFlags;
  423.     SInt8                             precedence;
  424.     Boolean                         dontFrag;
  425.     SInt8                             timeToLive;
  426.     SInt8                             security;
  427.     SInt8                             optionCnt;
  428.     SInt8                             options[40];
  429.     Ptr                             userDataPtr;
  430. };
  431. typedef struct TCPOpenPB                TCPOpenPB;
  432.  
  433.  
  434. struct TCPSendPB {
  435.     SInt8                             ulpTimeoutValue;
  436.     SInt8                             ulpTimeoutAction;
  437.     SInt8                             validityFlags;
  438.     Boolean                         pushFlag;
  439.     Boolean                         urgentFlag;
  440.     SInt8                             filler;                        /* Filler for proper byte alignment     */
  441.     Ptr                             wdsPtr;
  442.     unsigned long                     sendFree;
  443.     unsigned short                     sendLength;
  444.     Ptr                             userDataPtr;
  445. };
  446. typedef struct TCPSendPB                TCPSendPB;
  447.  
  448. /* for receive and return rcv buff calls */
  449. /*   Note: the filler in the following structure is in a different location than */
  450. /*         that specified in the Programmer's Guide.  */
  451.  
  452. struct TCPReceivePB {
  453.     SInt8                             commandTimeoutValue;
  454.     Boolean                         markFlag;
  455.     Boolean                         urgentFlag;
  456.     SInt8                             filler;                        /* Filler for proper byte alignment  */
  457.     Ptr                             rcvBuff;
  458.     unsigned short                     rcvBuffLen;
  459.     Ptr                             rdsPtr;
  460.     unsigned short                     rdsLength;
  461.     unsigned short                     secondTimeStamp;
  462.     Ptr                             userDataPtr;
  463. };
  464. typedef struct TCPReceivePB                TCPReceivePB;
  465.  
  466.  
  467. struct TCPClosePB {
  468.     SInt8                             ulpTimeoutValue;
  469.     SInt8                             ulpTimeoutAction;
  470.     SInt8                             validityFlags;
  471.     SInt8                             filler;                        /* Filler for proper byte alignment     */
  472.     Ptr                             userDataPtr;
  473. };
  474. typedef struct TCPClosePB                TCPClosePB;
  475.  
  476. struct HistoBucket {
  477.     unsigned short                     value;
  478.     unsigned long                     counter;
  479. };
  480. typedef struct HistoBucket                HistoBucket;
  481. enum {
  482.     NumOfHistoBuckets            = 7
  483. };
  484.  
  485.  
  486. struct TCPConnectionStats {
  487.     unsigned long                     dataPktsRcvd;
  488.     unsigned long                     dataPktsSent;
  489.     unsigned long                     dataPktsResent;
  490.     unsigned long                     bytesRcvd;
  491.     unsigned long                     bytesRcvdDup;
  492.     unsigned long                     bytesRcvdPastWindow;
  493.     unsigned long                     bytesSent;
  494.     unsigned long                     bytesResent;
  495.     unsigned short                     numHistoBuckets;
  496.     HistoBucket                     sentSizeHisto[7];
  497.     unsigned short                     lastRTT;
  498.     unsigned short                     tmrSRTT;
  499.     unsigned short                     rttVariance;
  500.     unsigned short                     tmrRTO;
  501.     SInt8                             sendTries;
  502.     SInt8                             sourchQuenchRcvd;
  503. };
  504. typedef struct TCPConnectionStats        TCPConnectionStats;
  505.  
  506. struct TCPStatusPB {
  507.     SInt8                             ulpTimeoutValue;
  508.     SInt8                             ulpTimeoutAction;
  509.     long                             unused;
  510.     ip_addr                         remoteHost;
  511.     tcp_port                         remotePort;
  512.     ip_addr                         localHost;
  513.     tcp_port                         localPort;
  514.     SInt8                             tosFlags;
  515.     SInt8                             precedence;
  516.     SInt8                             connectionState;
  517.     SInt8                             filler;                        /* Filler for proper byte alignment     */
  518.     unsigned short                     sendWindow;
  519.     unsigned short                     rcvWindow;
  520.     unsigned short                     amtUnackedData;
  521.     unsigned short                     amtUnreadData;
  522.     Ptr                             securityLevelPtr;
  523.     unsigned long                     sendUnacked;
  524.     unsigned long                     sendNext;
  525.     unsigned long                     congestionWindow;
  526.     unsigned long                     rcvNext;
  527.     unsigned long                     srtt;
  528.     unsigned long                     lastRTT;
  529.     unsigned long                     sendMaxSegSize;
  530.     TCPConnectionStats *            connStatPtr;
  531.     Ptr                             userDataPtr;
  532. };
  533. typedef struct TCPStatusPB                TCPStatusPB;
  534.  
  535. struct TCPAbortPB {
  536.     Ptr                             userDataPtr;
  537. };
  538. typedef struct TCPAbortPB                TCPAbortPB;
  539.  
  540. struct TCPParam {
  541.     unsigned long                     tcpRtoA;
  542.     unsigned long                     tcpRtoMin;
  543.     unsigned long                     tcpRtoMax;
  544.     unsigned long                     tcpMaxSegSize;
  545.     unsigned long                     tcpMaxConn;
  546.     unsigned long                     tcpMaxWindow;
  547. };
  548. typedef struct TCPParam                    TCPParam;
  549.  
  550. struct TCPStats {
  551.     unsigned long                     tcpConnAttempts;
  552.     unsigned long                     tcpConnOpened;
  553.     unsigned long                     tcpConnAccepted;
  554.     unsigned long                     tcpConnClosed;
  555.     unsigned long                     tcpConnAborted;
  556.     unsigned long                     tcpOctetsIn;
  557.     unsigned long                     tcpOctetsOut;
  558.     unsigned long                     tcpOctetsInDup;
  559.     unsigned long                     tcpOctetsRetrans;
  560.     unsigned long                     tcpInputPkts;
  561.     unsigned long                     tcpOutputPkts;
  562.     unsigned long                     tcpDupPkts;
  563.     unsigned long                     tcpRetransPkts;
  564. };
  565. typedef struct TCPStats                    TCPStats;
  566.  
  567. typedef StreamPtr *                        StreamPPtr;
  568.  
  569. struct TCPGlobalInfoPB {
  570.     TCPParam *                        tcpParamPtr;
  571.     TCPStats *                        tcpStatsPtr;
  572.     StreamPPtr                         tcpCDBTable[1];
  573.     Ptr                             userDataPtr;
  574.     unsigned short                     maxTCPConnections;
  575. };
  576. typedef struct TCPGlobalInfoPB            TCPGlobalInfoPB;
  577. typedef struct TCPiopb                     TCPiopb;
  578. typedef CALLBACK_API_C( void , TCPIOCompletionProcPtr )(TCPiopb *iopb);
  579. typedef STACK_UPP_TYPE(TCPIOCompletionProcPtr)                     TCPIOCompletionUPP;
  580.  
  581. struct TCPiopb {
  582.     SInt8                             fill12[12];
  583.     TCPIOCompletionUPP                 ioCompletion;
  584.     short                             ioResult;
  585.     Ptr                             ioNamePtr;
  586.     short                             ioVRefNum;
  587.     short                             ioCRefNum;
  588.     short                             csCode;
  589.     StreamPtr                         tcpStream;
  590.     union {
  591.         TCPCreatePB                     create;
  592.         TCPOpenPB                         open;
  593.         TCPSendPB                         send;
  594.         TCPReceivePB                     receive;
  595.         TCPClosePB                         close;
  596.         TCPAbortPB                         abort;
  597.         TCPStatusPB                     status;
  598.         TCPGlobalInfoPB                 globalInfo;
  599.     }                                 csParam;
  600. };
  601.  
  602. enum {
  603.     UDPCreate                    = 20,
  604.     UDPRead                        = 21,
  605.     UDPBfrReturn                = 22,
  606.     UDPWrite                    = 23,
  607.     UDPRelease                    = 24,
  608.     UDPMaxMTUSize                = 25,
  609.     UDPStatus                    = 26,
  610.     UDPMultiCreate                = 27,
  611.     UDPMultiSend                = 28,
  612.     UDPMultiRead                = 29,
  613.     UDPCtlMax                    = 29
  614. };
  615.  
  616. enum {
  617.     UDPDataArrival                = 1,
  618.     UDPICMPReceived                = 2,
  619.     lastUDPEvent                = 32767
  620. };
  621.  
  622.  
  623. typedef unsigned short                     UDPEventCode;
  624. typedef CALLBACK_API( void , UDPNotifyProcPtr )(StreamPtr udpStream, unsigned short eventCode, Ptr userDataPtr, ICMPReport *icmpMsg);
  625. typedef STACK_UPP_TYPE(UDPNotifyProcPtr)                         UDPNotifyUPP;
  626. typedef unsigned short                     udp_port;
  627. /* for create and release calls */
  628.  
  629. struct UDPCreatePB {
  630.     Ptr                             rcvBuff;
  631.     unsigned long                     rcvBuffLen;
  632.     UDPNotifyUPP                     notifyProc;
  633.     unsigned short                     localPort;
  634.     Ptr                             userDataPtr;
  635.     udp_port                         endingPort;
  636. };
  637. typedef struct UDPCreatePB                UDPCreatePB;
  638.  
  639. struct UDPSendPB {
  640.     unsigned short                     reserved;
  641.     ip_addr                         remoteHost;
  642.     udp_port                         remotePort;
  643.     Ptr                             wdsPtr;
  644.     Boolean                         checkSum;
  645.     SInt8                             filler;                        /* Filler for proper byte alignment     */
  646.     unsigned short                     sendLength;
  647.     Ptr                             userDataPtr;
  648.     udp_port                         localPort;
  649. };
  650. typedef struct UDPSendPB                UDPSendPB;
  651. /* for receive and buffer return calls */
  652.  
  653. struct UDPReceivePB {
  654.     unsigned short                     timeOut;
  655.     ip_addr                         remoteHost;
  656.     udp_port                         remotePort;
  657.     Ptr                             rcvBuff;
  658.     unsigned short                     rcvBuffLen;
  659.     unsigned short                     secondTimeStamp;
  660.     Ptr                             userDataPtr;
  661.     ip_addr                         destHost;                    /* only for use with multi rcv */
  662.     udp_port                         destPort;                    /* only for use with multi rcv */
  663. };
  664. typedef struct UDPReceivePB                UDPReceivePB;
  665.  
  666. struct UDPMTUPB {
  667.     unsigned short                     mtuSize;
  668.     ip_addr                         remoteHost;
  669.     Ptr                             userDataPtr;
  670. };
  671. typedef struct UDPMTUPB                    UDPMTUPB;
  672. typedef struct UDPiopb                     UDPiopb;
  673. typedef CALLBACK_API_C( void , UDPIOCompletionProcPtr )(UDPiopb *iopb);
  674. typedef STACK_UPP_TYPE(UDPIOCompletionProcPtr)                     UDPIOCompletionUPP;
  675.  
  676. struct UDPiopb {
  677.     SInt8                             fill12[12];
  678.     UDPIOCompletionUPP                 ioCompletion;
  679.     short                             ioResult;
  680.     Ptr                             ioNamePtr;
  681.     short                             ioVRefNum;
  682.     short                             ioCRefNum;
  683.     short                             csCode;
  684.     StreamPtr                         udpStream;
  685.     union {
  686.         UDPCreatePB                     create;
  687.         UDPSendPB                         send;
  688.         UDPReceivePB                     receive;
  689.         UDPMTUPB                         mtu;
  690.     }                                 csParam;
  691. };
  692.  
  693. #if OPAQUE_UPP_TYPES
  694.     EXTERN_API(GetIPIOCompletionUPP)
  695.     NewGetIPIOCompletionUPP           (GetIPIOCompletionProcPtr userRoutine);
  696.  
  697.     EXTERN_API(IPIOCompletionUPP)
  698.     NewIPIOCompletionUPP           (IPIOCompletionProcPtr    userRoutine);
  699.  
  700.     EXTERN_API(ICMPEchoNotifyUPP)
  701.     NewICMPEchoNotifyUPP           (ICMPEchoNotifyProcPtr    userRoutine);
  702.  
  703.     EXTERN_API(TCPNotifyUPP)
  704.     NewTCPNotifyUPP                   (TCPNotifyProcPtr        userRoutine);
  705.  
  706.     EXTERN_API(TCPIOCompletionUPP)
  707.     NewTCPIOCompletionUPP           (TCPIOCompletionProcPtr    userRoutine);
  708.  
  709.     EXTERN_API(UDPNotifyUPP)
  710.     NewUDPNotifyUPP                   (UDPNotifyProcPtr        userRoutine);
  711.  
  712.     EXTERN_API(UDPIOCompletionUPP)
  713.     NewUDPIOCompletionUPP           (UDPIOCompletionProcPtr    userRoutine);
  714.  
  715.     EXTERN_API(void)
  716.     DisposeGetIPIOCompletionUPP       (GetIPIOCompletionUPP    userUPP);
  717.  
  718.     EXTERN_API(void)
  719.     DisposeIPIOCompletionUPP       (IPIOCompletionUPP        userUPP);
  720.  
  721.     EXTERN_API(void)
  722.     DisposeICMPEchoNotifyUPP       (ICMPEchoNotifyUPP        userUPP);
  723.  
  724.     EXTERN_API(void)
  725.     DisposeTCPNotifyUPP               (TCPNotifyUPP            userUPP);
  726.  
  727.     EXTERN_API(void)
  728.     DisposeTCPIOCompletionUPP       (TCPIOCompletionUPP        userUPP);
  729.  
  730.     EXTERN_API(void)
  731.     DisposeUDPNotifyUPP               (UDPNotifyUPP            userUPP);
  732.  
  733.     EXTERN_API(void)
  734.     DisposeUDPIOCompletionUPP       (UDPIOCompletionUPP        userUPP);
  735.  
  736.     EXTERN_API(void)
  737.     InvokeGetIPIOCompletionUPP       (GetAddrParamBlock *        iopb,
  738.                                     GetIPIOCompletionUPP    userUPP);
  739.  
  740.     EXTERN_API(void)
  741.     InvokeIPIOCompletionUPP           (ICMPParamBlock *        iopb,
  742.                                     IPIOCompletionUPP        userUPP);
  743.  
  744.     EXTERN_API(void)
  745.     InvokeICMPEchoNotifyUPP           (ICMPParamBlock *        iopb,
  746.                                     ICMPEchoNotifyUPP        userUPP);
  747.  
  748.     EXTERN_API(void)
  749.     InvokeTCPNotifyUPP               (StreamPtr                tcpStream,
  750.                                     unsigned short            eventCode,
  751.                                     Ptr                        userDataPtr,
  752.                                     unsigned short            terminReason,
  753.                                     ICMPReport *            icmpMsg,
  754.                                     TCPNotifyUPP            userUPP);
  755.  
  756.     EXTERN_API(void)
  757.     InvokeTCPIOCompletionUPP       (TCPiopb *                iopb,
  758.                                     TCPIOCompletionUPP        userUPP);
  759.  
  760.     EXTERN_API(void)
  761.     InvokeUDPNotifyUPP               (StreamPtr                udpStream,
  762.                                     unsigned short            eventCode,
  763.                                     Ptr                        userDataPtr,
  764.                                     ICMPReport *            icmpMsg,
  765.                                     UDPNotifyUPP            userUPP);
  766.  
  767.     EXTERN_API(void)
  768.     InvokeUDPIOCompletionUPP       (UDPiopb *                iopb,
  769.                                     UDPIOCompletionUPP        userUPP);
  770.  
  771. #else
  772.     enum { uppGetIPIOCompletionProcInfo = 0x000000C1 };             /* no_return_value Func(4_bytes) */
  773.     enum { uppIPIOCompletionProcInfo = 0x000000C1 };                 /* no_return_value Func(4_bytes) */
  774.     enum { uppICMPEchoNotifyProcInfo = 0x000000C1 };                 /* no_return_value Func(4_bytes) */
  775.     enum { uppTCPNotifyProcInfo = 0x0000EEC0 };                     /* pascal no_return_value Func(4_bytes, 2_bytes, 4_bytes, 2_bytes, 4_bytes) */
  776.     enum { uppTCPIOCompletionProcInfo = 0x000000C1 };                 /* no_return_value Func(4_bytes) */
  777.     enum { uppUDPNotifyProcInfo = 0x00003EC0 };                     /* pascal no_return_value Func(4_bytes, 2_bytes, 4_bytes, 4_bytes) */
  778.     enum { uppUDPIOCompletionProcInfo = 0x000000C1 };                 /* no_return_value Func(4_bytes) */
  779.     #define NewGetIPIOCompletionUPP(userRoutine)                     (GetIPIOCompletionUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppGetIPIOCompletionProcInfo, GetCurrentArchitecture())
  780.     #define NewIPIOCompletionUPP(userRoutine)                         (IPIOCompletionUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppIPIOCompletionProcInfo, GetCurrentArchitecture())
  781.     #define NewICMPEchoNotifyUPP(userRoutine)                         (ICMPEchoNotifyUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppICMPEchoNotifyProcInfo, GetCurrentArchitecture())
  782.     #define NewTCPNotifyUPP(userRoutine)                             (TCPNotifyUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppTCPNotifyProcInfo, GetCurrentArchitecture())
  783.     #define NewTCPIOCompletionUPP(userRoutine)                         (TCPIOCompletionUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppTCPIOCompletionProcInfo, GetCurrentArchitecture())
  784.     #define NewUDPNotifyUPP(userRoutine)                             (UDPNotifyUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppUDPNotifyProcInfo, GetCurrentArchitecture())
  785.     #define NewUDPIOCompletionUPP(userRoutine)                         (UDPIOCompletionUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppUDPIOCompletionProcInfo, GetCurrentArchitecture())
  786.     #define DisposeGetIPIOCompletionUPP(userUPP)                     DisposeRoutineDescriptor(userUPP)
  787.     #define DisposeIPIOCompletionUPP(userUPP)                         DisposeRoutineDescriptor(userUPP)
  788.     #define DisposeICMPEchoNotifyUPP(userUPP)                         DisposeRoutineDescriptor(userUPP)
  789.     #define DisposeTCPNotifyUPP(userUPP)                             DisposeRoutineDescriptor(userUPP)
  790.     #define DisposeTCPIOCompletionUPP(userUPP)                         DisposeRoutineDescriptor(userUPP)
  791.     #define DisposeUDPNotifyUPP(userUPP)                             DisposeRoutineDescriptor(userUPP)
  792.     #define DisposeUDPIOCompletionUPP(userUPP)                         DisposeRoutineDescriptor(userUPP)
  793.     #define InvokeGetIPIOCompletionUPP(iopb, userUPP)                 CALL_ONE_PARAMETER_UPP((userUPP), uppGetIPIOCompletionProcInfo, (iopb))
  794.     #define InvokeIPIOCompletionUPP(iopb, userUPP)                     CALL_ONE_PARAMETER_UPP((userUPP), uppIPIOCompletionProcInfo, (iopb))
  795.     #define InvokeICMPEchoNotifyUPP(iopb, userUPP)                     CALL_ONE_PARAMETER_UPP((userUPP), uppICMPEchoNotifyProcInfo, (iopb))
  796.     #define InvokeTCPNotifyUPP(tcpStream, eventCode, userDataPtr, terminReason, icmpMsg, userUPP)  CALL_FIVE_PARAMETER_UPP((userUPP), uppTCPNotifyProcInfo, (tcpStream), (eventCode), (userDataPtr), (terminReason), (icmpMsg))
  797.     #define InvokeTCPIOCompletionUPP(iopb, userUPP)                 CALL_ONE_PARAMETER_UPP((userUPP), uppTCPIOCompletionProcInfo, (iopb))
  798.     #define InvokeUDPNotifyUPP(udpStream, eventCode, userDataPtr, icmpMsg, userUPP)  CALL_FOUR_PARAMETER_UPP((userUPP), uppUDPNotifyProcInfo, (udpStream), (eventCode), (userDataPtr), (icmpMsg))
  799.     #define InvokeUDPIOCompletionUPP(iopb, userUPP)                 CALL_ONE_PARAMETER_UPP((userUPP), uppUDPIOCompletionProcInfo, (iopb))
  800. #endif
  801. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  802. #define NewGetIPIOCompletionProc(userRoutine)                     NewGetIPIOCompletionUPP(userRoutine)
  803. #define NewIPIOCompletionProc(userRoutine)                         NewIPIOCompletionUPP(userRoutine)
  804. #define NewICMPEchoNotifyProc(userRoutine)                         NewICMPEchoNotifyUPP(userRoutine)
  805. #define NewTCPNotifyProc(userRoutine)                             NewTCPNotifyUPP(userRoutine)
  806. #define NewTCPIOCompletionProc(userRoutine)                     NewTCPIOCompletionUPP(userRoutine)
  807. #define NewUDPNotifyProc(userRoutine)                             NewUDPNotifyUPP(userRoutine)
  808. #define NewUDPIOCompletionProc(userRoutine)                     NewUDPIOCompletionUPP(userRoutine)
  809. #define CallGetIPIOCompletionProc(userRoutine, iopb)            InvokeGetIPIOCompletionUPP(iopb, userRoutine)
  810. #define CallIPIOCompletionProc(userRoutine, iopb)                InvokeIPIOCompletionUPP(iopb, userRoutine)
  811. #define CallICMPEchoNotifyProc(userRoutine, iopb)                InvokeICMPEchoNotifyUPP(iopb, userRoutine)
  812. #define CallTCPNotifyProc(userRoutine, tcpStream, eventCode, userDataPtr, terminReason, icmpMsg) InvokeTCPNotifyUPP(tcpStream, eventCode, userDataPtr, terminReason, icmpMsg, userRoutine)
  813. #define CallTCPIOCompletionProc(userRoutine, iopb)                InvokeTCPIOCompletionUPP(iopb, userRoutine)
  814. #define CallUDPNotifyProc(userRoutine, udpStream, eventCode, userDataPtr, icmpMsg) InvokeUDPNotifyUPP(udpStream, eventCode, userDataPtr, icmpMsg, userRoutine)
  815. #define CallUDPIOCompletionProc(userRoutine, iopb)                InvokeUDPIOCompletionUPP(iopb, userRoutine)
  816.  
  817.  
  818. #if PRAGMA_STRUCT_ALIGN
  819.     #pragma options align=reset
  820. #elif PRAGMA_STRUCT_PACKPUSH
  821.     #pragma pack(pop)
  822. #elif PRAGMA_STRUCT_PACK
  823.     #pragma pack()
  824. #endif
  825.  
  826. #ifdef PRAGMA_IMPORT_OFF
  827. #pragma import off
  828. #elif PRAGMA_IMPORT
  829. #pragma import reset
  830. #endif
  831.  
  832. #ifdef __cplusplus
  833. }
  834. #endif
  835.  
  836. #endif /* __MACTCP__ */
  837.  
  838.